import dva from 'dva';
import createLoading from 'dva-loading';
/*import {createHashHistory, } from 'history';*/

import './index.css';

// 1. Initialize
const app = dva({
    /*   history: useRouterHistory(createHashHistory)(),
    history: browserHistory,
*/
});

// 2. Plugins
// app.use({});
app.use(createLoading({ effects: true }));
//用于异步加载model检测,建议用app.modelX而非app.model
const cached = {};
app.modelX = (...models) => {
    for (const model of models) {
        if (!cached[model.namespace]) {
            app.model(model);
            cached[model.namespace] = 1;
        }
    }
};
// 3. Model
app.model(require('./models/app'));
app.model(require('./models/flex'));
// 4. Router
app.router(require('./router'));

// 5. Start
app.start('#root');
